package com.bi.design.mqtt.borker.message;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created by wizzer on 2018
 */
@Slf4j
@Component
public class MessageIdService implements IMessageIdService, InitializingBean {

    private AtomicInteger count = new AtomicInteger(0);
    @Override
    public int getNextMessageId() {
        return count.incrementAndGet();
    }

    /**
     * 每次重启的时候初始化
     */
    @Override
    public void afterPropertiesSet() throws Exception {

    }
}
